<?php
/*
 * 手机客户端 学生列表
 * 2013-12-04
 */
 
include "inc/public_header.php";

include "func/user.php";				//用户信息处理函数


$reJson = array(); //构建返回值
$reJson["success"]='1';


//页数，第一页为0
$page			= $_REQUEST["page"]; 
//每页记录数			
$pagesize		= $_REQUEST["pagesize"];

//图片地址
$IMG_DEFAULT_PATH = "http://www.chinalaohu.com/images/news/";

//头像根路径
$LOGO_BASE_PATH = "http://www.chinalaohu.com/modules/miniature.php?w=150&h=150&p=/uploads/zjl_ilogo/";

//头像根路径
$PIC_BASE_PATH = "http://www.chinalaohu.com/img1/uploads/zjl_ilogo/";

//默认头像
$LOGO_DEFAULT_PATH = "http://www.chinalaohu.com/images/zjl/logo.png";

if(!isset($page)){
	$page = 0;
}
if(!isset($pagesize)){
	$pagesize = 10; //默认每页10条
}
$sql="select count(uid) as ct from new_weituo_person where good_student=1";
$db->query($sql);
$db->next_record();
$reJson["count"] = $db->f("ct");

$sql="select a.nickname,a.ilogo_path,b.aname,a.uid,a.picture,a.grsm,a.realname,a.picture
from new_weituo_person a 
LEFT JOIN new_weituo_xuexiao b on a.xuexiao_id=b.id
where a.good_student=1";
$sql .= "  limit ".($page * $pagesize).",".$pagesize;
$db->query($sql);
$student=array();

while($db->next_record()){
	if(!$db->f("picture")){
		$bigImg=$LOGO_DEFAULT_PATH;
		$img=$LOGO_DEFAULT_PATH;
	}else{
		$bigImg=$PIC_BASE_PATH.$db->f("picture");
		$img=$LOGO_BASE_PATH.$db->f("picture");
	}
	$student[]=array(
		"name"=>(string)$db->f("realname")
		//,"nickname"=>(string)$db->f("nickname")
		,"id"=>$db->f("uid")
		,"imgUrl"=>$img
		,"bigImgUrl"=>$bigImg
		//,"college"=>(string)$db->f("aname")
		//,"picture"=>(string)$IMG_DEFAULT_PATH.$db->f("picture")
		,"introduce"=>"学院：".$db->f("aname")."\n\n个人介绍：".$db->f("grsm")
	);
}
$reJson["list"]=$student;
echo json_encode($reJson);
 ?>